<!DOCTYPE html>
<html lang="en">
<head>
     <meta charset="UTF-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Document</title>
</head>
<style>
 #box{
   width:100px;
   height:100px;
   background-color:red;
   position: absolute;
 }
</style>
<body height="1000px">
  <script>
 window.onload=function(){
   var box=document.getElementById("box");
   document.onmousemove=function(event){
     event=event||window.event;
     var left=event.clientX;
     var top=event.clientY;
     var st=document.body.scrollTop;
     var sl=document.body.scrollTop
     //var left=event.pageX;
     //var top=event.pageY;
     box.style.left=left+sl+'px';
     box.style.top=top+st+'px';
   }
 }
</script>
<body>
<div id="box"></div>
</body>
</html>                                                                                                                                 